<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo (C("SYS_TITLE")); ?></title>
<link href="/wwyl/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="/wwyl/Public/Admin/css/page.css" rel="stylesheet" type="text/css" />
<style>
.file {width:102px;height:34px;opacity:0;filter:alpha(opacity=0);cursor:pointer;}
<!--权限样式-->
#wrap a{text-decoration:none; color:#000;}
#wrap a:hover{ color:#CCC;}
#wrap{ width:94%; height:auto; overflow:hidden; margin:20px auto; padding:10px 20px; border:1px solid #ccc;}
#wrap .add-app{ display:block; width:100px; height:20px; line-height:20px; text-align:center; background:#670768; color:#fff; border-radius:4px;}
#wrap .app{ padding:5px; border:1px solid #f6f6f6; border-radius:4px; width:1000px;}
#wrap .app p{ height:20px; line-height:20px;}
#wrap .app p strong{ font-size:20px; color:#0b99d8}
#wrap .app dl{ margin:10px 0; border:1px solid #f6f6f6; height:auto; overflow:hidden;border-radius:4px;}
#wrap .app dl dt{ display:block; height:25px; line-height:25px; background:#e6e6fa; text-indent:25px;}
#wrap .app dl dt strong{ font-size:14px; color:#61a1fa;}
#wrap .app dl dd{ margin:5px; display:block; height:18px;; width:185px; line-height:18px; text-align:left;  float:left; font-size:16px;} 
</style>

<!--编辑器-->
<script type="text/javascript" src="/wwyl/Public/Admin/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/wwyl/Public/Admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/wwyl/Public/Admin/ueditor/ueditor.all.min.js"></script>

<!---->
<script language="JavaScript" src="/wwyl/Public/Admin/js/jquery.js"></script>
<script type="text/javascript">
	$(function(){	
		//顶部导航切换
		$(".nav li a").click(function(){
			$(".nav li a.selected").removeClass("selected")
			$(this).addClass("selected");
		})	
	})	
	
	$(function(){	
		//导航切换
		$(".menuson li").click(function(){
			$(".menuson li.active").removeClass("active")
			$(this).addClass("active");
		});
		
		$('.title').click(function(){
			var $ul = $(this).next('ul');
			$('dd').find('ul').slideUp();
			if($ul.is(':visible')){
				$(this).next('ul').slideUp();
			}else{
				$(this).next('ul').slideDown();
			}
		});
	})	
	
	$(document).ready(function(){
	  $(".click").click(function(){
	  $(".tip").fadeIn(200);
	  });
	  
	  $(".tiptop a").click(function(){
	  $(".tip").fadeOut(200);
	});
	
	  $(".sure").click(function(){
	  $(".tip").fadeOut(100);
	});
	
	  $(".cancel").click(function(){
	  $(".tip").fadeOut(100);
	});
	
	});
	
	//tabl 切换
	$(document).ready(function(e) {
		$('#sel li').click(function(){
			$(".tab-front").removeClass("tab-front").addClass("tab-back");
			$('#sel li a').removeClass();	
			$(this).find('a').attr('class','selected');
			$(this).removeClass("tab-back").addClass("tab-front");
			var i = $(this).index();
			$(".tabbody-div").hide();
			$(".tabbody-div").eq(i).show();
		});
	});
</script>

</head>

<link rel="stylesheet" type="text/css" href="/wwyl/Public/Admin/css/style.css">
<script type="text/javascript" src="/wwyl/Public/Admin/js/jquery-3.2.0.min.js"></script>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>首页</li>
    <li>文章列表</li>
  </ul>
</div>
<form action="<?php echo U('Article/index');?>" method="post">
<div class="rightinfo">
  <div class="tools">
    <ul class="toolbar">
      <a href="<?php echo U('Article/add');?>"><li><span><img src="/wwyl/Public/Admin/images/t01.png" /></span>添加</li></a>
      <a href="" id="delall"><li><span><img src="/wwyl/Public/Admin/images/t03.png" /></span>批量回收</li></a>
      <li><select name="cid" style="width:150px; height:34px; border:1px solid #CED9DF; line-height:34px;">
            <option value="0">栏目搜索</option>
            <?php if(is_array($cate)): foreach($cate as $key=>$v): ?><option value="<?php echo ($v['id']); ?>"><?php echo ($v['html']); echo ($v['name']); ?></option><?php endforeach; endif; ?>
      </select></li>
      <li><span><input type="text" name="seach"></span></li>
      <li><span><img src="/wwyl/Public/Admin/images/t01.png" /></span><span style="margin-top:7px; font-size:16px;"><input type="submit" value="搜索"></span></li>
    </ul>
  </div>
 
  <table class="tablelist">
    <thead>
      <tr>
        <th><input type="checkbox" id="selall"/></th>
        <th>ID</th>
        <th>标题</th>
        <th>缩图</th>
        <th>分类</th>
        <th>审核</th>
        <th>评论</th>
        <th>时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <?php if(is_array($article)): foreach($article as $key=>$v): ?><tr>
          <td><input type="checkbox" class="selall" name="id[]" value="<?php echo ($v['id']); ?>"/></td>
          <td><?php echo ($v['id']); ?></td>
          <td><?php echo (mb_substr($v['name'],0,20,'utf-8')); ?></td>
          <td>
          	<?php if($v['tpic'] !== ''): ?><img src="/wwyl/<?php echo ($v['tpic']); ?>" width="50" height="40"><?php else: ?> 无图<?php endif; ?>
          </td>
          <td style="font-weight:bold">[ <?php echo $v['category']['name'];?> ]</td>
          <td><?php if($v['lock'] == 1): ?>无需<?php else: ?><a style=" font-weight:bold;">审核</a><?php endif; ?></td>
          <td><?php if($v['comment'] == 1): ?>允许<?php else: ?><a style=" font-weight:bold;">禁止</a><?php endif; ?></td>
          <td><?php echo (date('Y-m-d H:i',$v['time'])); ?></td>
          <td>
          <a href="<?php echo U('Article/edit',array('id' => $v['id']));?>" class="tablelink">编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;
          <a href="<?php echo U('Article/del',array('id' => $v['id']));?>" class="tablelink" onclick="return confirm('确实要放入回收站吗？')">回收站</a>
          </td>
        </tr><?php endforeach; endif; ?>
    </tbody>
  </table>

  <div class="meneame">
    <div class="current"></div>
    <?php echo ($page); ?> 
  </div>
</div>  
</form>
<script>
/**/
$('#selall').click(function(){
	var chk = $(this).attr('checked');//获取当前的属性
	if(chk){
		$(".selall").attr("checked","checked");//设置当前的属性
	}else{
		$(".selall").removeAttr("checked");//移除当前的属性
	}
});

$(function() {
    var $subBox = $("input[name='id']");
    $subBox.click(function(){
        $(".selall").attr("checked",$subBox.length == $("input[name='id']:checked").length ? true : false);
	
	});	
	$("#delall").click(function(){
		if(confirm("确定回收勾选内容吗？")){
            var v='';
            var m=$('input[name="id[]"]:checked').length;
            var i=1;
            $('input[name="id[]"]:checked').each(function(){
                if(i==m){
                    v+=$(this).val();
                }else{
                    v+=$(this).val()+",";
                }
                i=i+1;
            });
            if(!v){
                alert('请选择您要回收的内容！');
            }else{
				//alert(v);//获取到选中的值 1,2,3,4 
				$.ajax({ 
                    type     : "GET", 
                    url      : "<?php echo U('Article/del');?>", 
					data     : {id:v},
					async    :  false,//同步才可以执行
					success  : function(data) {
						if(data == 1){
							alert('批量回收成功');
						}else{
							return false;
						}
                    } 
                }); 
            }
        }else{
            return false;
        }
	});
});
</script>
</body>
</html>